<?php
namespace Info\Controller;
use Info\Controller\CommonController;
use Common\Model\InfoContentModel;
use Common\Model\LinksModel;
use Common\Model\InfoCategoryModel;
class IndexController extends CommonController {

    public function index(){
        if(C('DEFAULT_THEME') == 'qinxi'){
            $this->indexQinxi();
        }else if(C('DEFAULT_THEME') == 'fenlei2'){
            $this->indexFenlei2();
        }else{
            $this->indexDefault();
        }

        $this->display(':index');
    }

    public function indexDefault(){
        $pid = I('pid','','int');
        $cid = I('cid','','int');
        $area = I('area','','int');
        $info = new InfoContentModel();
        $AllCategory = $this->getAllCategory();
        $infoListdata = $info->getInfoData($pid,$cid,$area);
        $phoneData = $info->getInfoByType(2);

        $categoryModel = new InfoCategoryModel;
        $category = $categoryModel->getCategory(1);
        $linksModel = new LinksModel();
        $links = $linksModel->getLinks();
        $pageShow = $this->PageShow($infoListdata['count']);
        $this->assign('data',$infoListdata['data'])
            ->assign('flinks',$links)
            ->assign('cid',$cid)
            ->assign('pid',$pid)
            ->assign('area',$area)
            ->assign('phoneData',$phoneData)
            ->assign('allCategory',$AllCategory)
            ->assign('pageShow',$pageShow)
            ->assign("category",$category);
    }

    public function indexQinxi(){
        $info = new InfoContentModel();
        $AllCategory = $this->getCategoryByPid();
        $infoListdataCid[0] = $this->getInfoInCidArr('top',1);
        $infoListdataCid[-1] = $this->getInfoInCidArr('',6);
        $infoListdataCid[-2] = $this->getInfoInCidArr('thum',2);

        $infoListdataCid[1] = $this->getInfoInCidArr(array_column($AllCategory['data'][1],'id'));
        $infoListdataCid[2] = $this->getInfoInCidArr(array_column($AllCategory['data'][2],'id'));
        $infoListdataCid[4] = $this->getInfoInCidArr(array_column($AllCategory['data'][4],'id'));
        $infoListdataCid[5] = $this->getInfoInCidArr(array_column($AllCategory['data'][5],'id'));
        $infoListdataCid[6] = $this->getInfoInCidArr(array_column($AllCategory['data'][6],'id'));
        $infoListdataCid[7] = $this->getInfoInCidArr(array_column($AllCategory['data'][7],'id'),12);

        $linksModel = new LinksModel();
        $links = $linksModel->getLinks();

        $this->assign('data',$infoListdataCid)
            ->assign('flinks',$links)
            ->assign("category",$AllCategory);
    }

    public function indexFenlei2()
    {
        $info = new InfoContentModel();
        $AllCategory = $this->getCategoryByPid();

        $infoListdataCid[0] = $this->getInfoInCidArr('top',14);
        $infoListdataCid[-1] = $this->getInfoInCidArr('',7);
        $infoListdataCid[1] = $this->getInfoInCidArr(array_column($AllCategory['data'][1],'id'),9);
        $infoListdataCid[2] = $this->getInfoInCidArr(array_column($AllCategory['data'][2],'id'),9);
        $infoListdataCid[4] = $this->getInfoInCidArr(array_column($AllCategory['data'][4],'id'),15);
        $infoListdataCid[5] = $this->getInfoInCidArr(array_column($AllCategory['data'][5],'id'),10);
        $infoListdataCid[6] = $this->getInfoInCidArr(array_column($AllCategory['data'][6],'id'),2);
        $infoListdataCid[7] = $this->getInfoInCidArr(array_column($AllCategory['data'][7],'id'),13);
        $infoListdataCid[8] = $this->getInfoInCidArr(array_column($AllCategory['data'][8],'id'),11);
        $infoListdataCid[9] = $this->getInfoInCidArr(array_column($AllCategory['data'][9],'id'),6);
        $infoListdataCid[72] = $this->getInfoInCidArr(array_column($AllCategory['data'][72],'id'),2);
        $linksModel = new LinksModel();
        $links = $linksModel->getLinks();

        $this->assign('data',$infoListdataCid)
            ->assign('flinks',$links)
            ->assign("category",$AllCategory);
    }
}